#!/usr/bin/env python
# -*- coding: utf-8 -*-
# @Time    : 2021/12/27 20:21
# @Author  : Sun
# @File    : modify_family_note.py
# @Software: PyCharm
import json

import requests

from common.read_yaml import ReadYaml
from common.write_log import WriteLog


class GetBannerList:
    _URL = ReadYaml().read_yaml().get('domain') + "/banner/getBannerList"
    _DATA = {
        # Android、IOS、PC
        "terminal": None,
        # 1为家族列表Banner，2为热门活动Banner
        "category": None
    }
    _HEADERS = {
        'platform': 'RN',
        'authorization': None,
        'Content-Type': 'application/json;charset=utf-8'
    }

    # 传入的JJUid必须对应为家族族长/管理员，dwPidOut为当前家族ID
    def get_banner_list(self, JJUid, terminal, category):
        self._DATA['terminal'] = terminal
        self._DATA['category'] = category
        self._HEADERS['authorization'] = ReadYaml().read_yaml(file_path="./config/family_token.yaml").get(JJUid)
        r = requests.request(
            method='POST',
            url=self._URL,
            data=json.dumps(
                self._DATA),
            headers=self._HEADERS)
        result = json.dumps(r.json(), ensure_ascii=False, indent=4)
        WriteLog().write_log().info(result)
        return result


if __name__ == '__main__':
    GetBannerList().get_banner_list(JJUid=106146624, terminal="RN", category=1)
